<?php
// .-----------------------------------------------------------------------------------
// |  Software: [HDPHP framework]
// |   Version: 2013.01
// |      Site: http://www.hdphp.com
// |-----------------------------------------------------------------------------------
// |    Author: 向军 <houdunwangxj@gmail.com>
// | Copyright (c) 2012-2013, http://houdunwang.com. All Rights Reserved.
// |-----------------------------------------------------------------------------------
// |   License: http://www.apache.org/licenses/LICENSE-2.0
// '-----------------------------------------------------------------------------------
class InfoControl extends CommonControl{

    // 文章列表
    function index(){
        
        if(IS_GET && $_GET['lid']){
            $lid = $_GET['lid'];
            $db = M('info');
            $where = 'isshow=1 ';
            $lids = $this->db_infolist->getLids($lid);
            $where .= ' and lid in('.$lids.')';
            $count = $db->count($where);
            $page = new page($count,10);
            $list = $db->where($where)->order("orders,addtime desc,id desc")->limit($page->limit())->all();
            
            $this->assign('list',$list);
            $this->assign('page',$page->show());
            $this->display();
        }else{
            return;
        }

  
    }

    /**
     * 内容显示
     * @return [type] [description]
     */
    function show(){

        if(IS_GET && $_GET['id']){
            $id = $_GET['id'];
            $db = M('info');
         
            $data = $db->where("id=$id and isshow=1")->one();
            // 上一篇
            $pre = $db->where("isshow=1 and lid=".$data['lid']." and addtime<".$data['addtime'])->one();
            p($pre);
            echo '<hr/>';
            $next= $db->where("isshow=1 and lid=".$data['lid']." and addtime>".$data['addtime'])->one();
            p($next);

            $this->assign('data',$data);
            $this->display();
        }else{
            return;
        }

  
    }
}
?>